package com.xcolud.redisdemo.services;

import com.xcolud.redisdemo.model.MsgVo;
import com.xcolud.redisdemo.model.constants.ComConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author songshiming
 * @date 2023/3/7 下午11:14
 * @des
 */
@Service
public class MqServices {

    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    /**
     * 往channel 渠道 发送消息
     * @param channel
     * @param msgVo
     */
    public void send(String channel,MsgVo msgVo){
        redisTemplate.convertAndSend(channel, msgVo);
        System.out.println(msgVo.toString());
    }
}
